package com.datasecops.scannerservices.watermark;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.sql.SQLException;



/**
 * @author: GeXiaoLong
 * @time: 2023/1/3 15:26
 */
@Service
@Slf4j
public class JNILinuxSo {
//    实现以下原生方法
    public native String print(String msg);
    public native int WmProcessJNI(String CfgFileName);

    public Integer text(){
//        String resource = Objects.requireNonNull(JNILinuxSo.class.getResource("/root/watermark/dso_dbwm/bin/Dbwm.so")).getPath();
//        log.error("这个指向的路径是:           "+resource);

        //这个加载绝对路径动态库
        System.load("/root/watermark/dso_dbwm/bin/Dbwm.so");
        JNILinuxSo jniWinSo = new JNILinuxSo();
        //System.out.println(jniWinSo.print("测试打印"));
//        jniWinSo.print("测试打印");
        int i = jniWinSo.WmProcessJNI("/root/watermark/dso_dbwm/WmCfg.txt");
        log.error("数据库水印组件的返回值是:   " + i );
//        jniWinSo.WmProcessJNI("/root/watermark/dso_dbwm/WmCfg.txt");
//        System.out.println(i);
//        jniWinSo.WmProcessJNI("/root/watermark/dso_dbwm/WmCfg.txt");


        return i ;
    }

    public static void main(String[] args) throws SQLException, IOException {
        //JNILinuxSo.
        MysqlDB.main(args);
    }



}
